<template>
    <view>
        <block v-if="detail != null">
          <!-- 地址 -->
          <view v-if="detail.order_model == 0 || detail.order_model == 2" class="address bg-white spacing-mb">
              <view class="address-base oh">
                  <text v-if="(detail.address_data.alias || null) != null" class="address-alias">{{detail.address_data.alias}}</text>
                  <text>{{detail.address_data.name}}</text>
                  <text class="fr">{{detail.address_data.tel}}</text>
              </view>
              <view class="address-detail oh">
                  <image class="icon fl" :src="common_static_url+'mini/user-address.png'" mode="widthFix" />
                  <view class="text fr">
                    {{detail.address_data.province_name}}{{detail.address_data.city_name}}{{detail.address_data.county_name}}{{detail.address_data.address}}
                  </view>
              </view>
          </view>
        
          <!-- 商品列表 -->
          <view class="goods bg-white spacing-mb">
              <view v-for="(item, index) in detail.items" :key="index" class="goods-item br-b-dashed oh">
				<navigator :url="'/pages/goods-detail/goods-detail?goods_id=' + item.goods_id" hover-class="none">
                  <image class="goods-image fl" :src="item.images" mode="aspectFill" />
                  <view class="goods-base">
                    <view class="goods-title multi-text">{{item.title}}</view>
                    <block v-if="item.spec != null">
                      <view class="goods-attribute cr-888" v-for="(sv, si) in item.spec" :key="si">>
                        {{sv.type}}:{{sv.value}}
                      </view>
                    </block>
                  </view>
                  <view class="oh goods-price">
                    <text class="sales-price">{{detail.currency_data.currency_symbol}}{{item.price}}</text>
                    <text v-if="item.original_price > 0" class="original-price">{{detail.currency_data.currency_symbol}}{{item.original_price}}</text>
                    <text class="buy-number">x{{item.buy_number}}</text>
                  </view>
                </navigator>
              </view>
              <view class="order-describe">{{detail.describe}}</view>
          </view>
        
          <!-- 快递数据 -->
		  <block v-if="(detail.express_data || null) != null && detail.express_data.length > 0 && express_info.length > 0">
		  	<view v-for="(item, index) in express_info" :key="index" class="panel-item spacing-mt bg-white">
		  		<view class="panel-title">
		  			<image v-if="item.express_icon != ''" class="exp-image" :src="item.express_icon" mode="aspectFill" />
		  			<view class="exp-title">
		  				<view class="exp-title-cc">{{item.express_name}}</view>
		  				<view class="exp-num">
		  					<text class="dis-inline-block va-m">{{item.express_number}}</text>
		  					<button type="primary" hover-class="none" size="mini" class="dis-inline-block va-m" @tap="text_copy_event" :data-value="item.express_number">复制</button>
		  				</view>
		  			</view>
		  			<view class="exp-status">{{item.deliverystatus_text}}</view>
		  			<view v-if="item.note != ''" class="exp-note">{{item.note}}</view>
		  		</view>
		  		<view v-if="item.Traces.length > 0" class="panel-content bg-white">
		  			<view v-for="(item2, index2) in item.Traces" :key="index2" class="item">
		  				<view class="dian"></view>
		  				<view class="content">{{item2.AcceptStation}}</view>
		  				<view class="title">{{item2.AcceptTime}}</view>
		  			</view>
		  		</view>
		  	</view>
		  </block>
        
		  <!-- 结尾 -->
		  <component-bottom-line :prop-status="data_bottom_line_status"></component-bottom-line>
        </block>
		<block v-else>
		    <!-- 提示信息 -->
		    <component-no-data :prop-status="data_list_loding_status" :prop-msg="data_list_loding_msg"></component-no-data>
		</block>
    </view>
</template>
<script>
    const app = getApp();
    import componentNoData from "@/components/no-data/no-data";
    import componentBottomLine from "@/components/bottom-line/bottom-line";

    var common_static_url = app.globalData.get_static_url('aliquanqiuexpress', true);
    export default {
        data() {
            return {
                common_static_url: common_static_url,
                params: null,
                data_list_loding_status: 1,
                data_list_loding_msg: '',
                data_bottom_line_status: false,
                detail: null,
                extension_data: [],
                site_fictitious: null,
				express_info: [],
            };
        },

        components: {
            componentNoData,
            componentBottomLine
        },
        props: {},

        onLoad(params) {
            //params['id'] = 5;
            this.setData({
                params: params
            });
        },

        onShow() {
			app.globalData.page_event_onshow_handle();
            // 数据加载
            this.init();
        },

        // 下拉刷新
        onPullDownRefresh() {
            this.init();
        },

        methods: {
            // 获取数据
            init() {
                var self = this;
                uni.showLoading({
                    title: this.$t('common.loading_in_text'),
                });
                this.setData({
                    data_list_loding_status: 1
                });
                uni.request({
                    url: app.globalData.get_request_url("index", "index", "aliquanqiuexpress"),
                    method: "POST",
                    data: {
                        order_id: this.params.order_id,
						business_type: this.params.business_type || ''
                    },
                    dataType: "json",
                    success: res => {console.log(res);
                        uni.hideLoading();
                        uni.stopPullDownRefresh();
                        if (res.data.code == 0) {
                            var data = res.data.data;
                            self.setData({
                                express_info: data.data || [],
                                data_list_loding_status: 3,
                                data_bottom_line_status: true,
                                data_list_loding_msg: ''
                            });
                        } else {
                            self.setData({
                                data_list_loding_status: 2,
                                data_bottom_line_status: false,
                                data_list_loding_msg: res.data.msg
                            });
                            if (app.globalData.is_login_check(res.data, self, 'init')) {
                                app.globalData.showToast(res.data.msg);
                            }
                        }
                    },
                    fail: () => {
                        uni.hideLoading();
                        uni.stopPullDownRefresh();
                        self.setData({
                            data_list_loding_status: 2,
                            data_bottom_line_status: false,
                            data_list_loding_msg: this.$t('common.internet_error_tips')
                        });
                        app.globalData.showToast(this.$t('common.internet_error_tips'));
                    }
                });
				
				this.get_order_info();
            },
			
			// 获取订单信息
			get_order_info() {
			    var self = this;
			    uni.showLoading({
			        title: this.$t('common.loading_in_text'),
			    });
			    this.setData({
			        data_list_loding_status: 1
			    });
			    uni.request({
			        url: app.globalData.get_request_url("detail", "order"),
			        method: "POST",
			        data: {
			            id: this.params.order_id
			        },
			        dataType: "json",
			        success: res => {
			            uni.hideLoading();
			            uni.stopPullDownRefresh();
			            if (res.data.code == 0) {
			                var data = res.data.data;
			                self.setData({
			                    detail: data.data,
			                    extension_data: data.data.extension_data || [],
			                    site_fictitious: data.site_fictitious || null,
			                    data_list_loding_status: 3,
			                    data_bottom_line_status: true,
			                    data_list_loding_msg: ''
			                });
			            } else {
			                self.setData({
			                    data_list_loding_status: 2,
			                    data_bottom_line_status: false,
			                    data_list_loding_msg: res.data.msg
			                });
			                if (app.globalData.is_login_check(res.data, self, 'init')) {
			                    app.globalData.showToast(res.data.msg);
			                }
			            }
			        },
			        fail: () => {
			            uni.hideLoading();
			            uni.stopPullDownRefresh();
			            self.setData({
			                data_list_loding_status: 2,
			                data_bottom_line_status: false,
			                data_list_loding_msg: this.$t('common.internet_error_tips')
			            });
			            app.globalData.showToast(this.$t('common.internet_error_tips'));
			        }
			    });
			},
			
			// 剪切板
			text_copy_event(e) {
				app.globalData.text_copy_event(e);
			},
        }
    };
</script>
<style>
    @import './aliquanqiuexpress.css';
</style>